<?php
namespace app\index\controller;

use app\commom\lib\Predis;
use app\commom\lib\Redis;
use app\commom\lib\Util;

class Index
{
    public function index()
    {
        return Util::responseFormat(1);
    }

    public function hello($name = 'ThinkPHP5')
    {
        echo  '-hello-' . $name;
    }

    public function testRedis(){
        try{
            $redis = Redis::getInstance()->getRedis();
            echo $redis->get('test');
        }catch (\Exception $exception){
            echo $exception->getMessage();
        }
    }

    public function testPredis(){
        try{
            $redis = Predis::getInstance()->getRedis();
            echo $redis->get('test');
        }catch (\Exception $exception){
            echo $exception->getMessage();
        }
    }

    public function testTask(){

        $httpServer = $_POST['swoole_http_server'];
        $taskData = [
            'method'=>'testTask',
            'data'=>['aaa','bbb'],
        ];
        $httpServer->task($taskData);
    }

    /**
     * 推送ws  message
    */
    public function pushMessage(){
        $httpServer = $_POST['swoole_ws_server'];
    }

    public function echophpinfo(){
        echo phpinfo();
    }

}
